package com.nuc.zyt.day04.demo.distributegifts;

/**
 * @ClassName Person1
 * @Description TODO
 * @Author 耀酱
 * @Date 2023/5/30 8:42
 * @Version 1.0
 */

public class Person extends Thread{

    public static int count = 100;

    @Override
    public void run() {
        while (true){
            synchronized (Person.class){
                if(count < 10){
                    // 不再发送礼物
                    break;
                }else {
                    count--;
                    System.out.println(Thread.currentThread().getName()+"正在发送礼物，礼物剩余"+count);
                }
            }
        }

    }
}
